<?php


	if($_REQUEST['type']!=''){
		$type = $_REQUEST['type']; 
		}
	
	if($type=='students')
		$type_head = 'Students';
	$table_name = $wpdb->prefix . "users";
	$table_name = 'parishioner';
	
	
	require_once("trackclass.php");
		$objTrack = new trackClass();
		
	$info=$_REQUEST["info"];

	if($info=="saved")
	{
		echo "<div class='updated' id='message'><p><strong>Member Added</strong>.</p></div>";
	}

	if($info=="upd")
	{
		echo "<div class='updated' id='message'><p><strong>Record Updated</strong>.</p></div>";
	}

	if($info=="del")
	{
		$delid=$_GET["did"];
		$wpdb->query("delete from ".$table_name." where id=".$delid);
		echo "<div class='updated' id='message'><p><strong>Record Deleted.</strong>.</p></div>";
	}

?>

<script type="text/javascript">
	/* <![CDATA[ */
	jQuery(document).ready(function(){
		jQuery('#memberlist').dataTable();
	});
	/* ]]> */

</script>


<div class="wrap">
    <h2>List of <?php echo $type_head;?>&nbsp; &nbsp; &nbsp; <a class="button add-new-h2" href="admin.php?page=member_add&act=add&type=<?php echo $type ?>">Add New</a></h2>
	 <table class="wp-list-table widefat fixed " id="memberlist">
	 <?php if($type == 'customer')  { ?>
		<thead>
			<tr>
				<th width="5%"><u >#ID</u></th>
				<th><u>First Name</u></th>
				<th><u>Last Name</u></th>
				<th width="10%" ><u>Purchase</u></th>
				<th><u>Email</u></th>
				
				
				<th><u>Registration</u></th>
				<th>Options</th>
			</tr>
		</thead>
		<tbody>
	<?php } else { ?>
	
	<thead>
			<tr>
				<th width="5%"><u >#ID</u></th>
				<th><u>Name</u></th>
				<th><u>Baptismal name</u></th>
				<th><u>Date of birth</u></th>
				<th><u>Phone_no</u></th>
				<th><u>Mob.No</u></th>
				<th width="6%"><u>Blood</u></th>
				<th width="10%"><u>Education</u></th>
				<th width="10%"><u>Occupation</u></th>
				<th width="15%"><u>Email</u></th>
				<th>View</th>
				<th>Edit</th>
			</tr>
		</thead>
		<tbody>

	<?php } ?>
<?php
		$family_id = 0;
		$family_id = $_GET['family_id'];		
		if($family_id>0)
			$addon1 = ' AND   family_id='.$family_id.'';	
		$sql = "SELECT * FROM parishioner 
				  WHERE  1 $addon1"; 		
			
		$result = mysql_query($sql) or die ('Error, query failed');
		 mysql_num_rows($result);
		if (mysql_num_rows($result) > 0 )
		{

		?>
				<script type="text/javascript">
				/* <![CDATA[ */
				jQuery(document).ready(function(){
					jQuery('#mytable').dataTable();
				});
				/* ]]> */

				</script>

<?php

			while ($row = mysql_fetch_assoc($result))
			{	$id        = $row['id'];
				$name  = $row['name'];
				$e_mail     = $row['e_mail'];
				$date_of_birth     = $row['date_of_birth'];
				$baptismal_name     = $row['baptismal_name'];
				$phone_no		    = $row['phone_no'];
				$mob_no		    	= $row['mob_no'];
				$blood_group	  	= $row['blood_group'];
				$education	  		= $row['education'];
				$occupation	  	    = $row['occupation'];
				
				
				
					?>
					<tr>
						<td><?php echo $id; ?></td>
						<td nowrap><?php echo $name; ?></td>
						
						<td nowrap><?php echo $baptismal_name; ?></td>
						<td nowrap><?php echo $date_of_birth; ?></td>
						<td nowrap><?php echo $phone_no; ?></td>
						<td nowrap><?php echo $mob_no; ?></td>	
						<td nowrap><?php echo $blood_group; ?></td>		
						<td nowrap><?php echo $education; ?></td>	
						<td nowrap><?php echo $occupation; ?></td>							
						<td nowrap><?php echo $e_mail; ?></td>
			
						<td>
						
						<u style="background-color:  #0074A2; text-align:center;color:#FFF; border: 2px solid; min-width:50px; display:block;
		border-radius: 50px;text-decoration:none;" ><a style="color:#FFF; text-decoration:none" href="admin.php?page=member_add&act=upd&id=<?php echo $id;?>&type=customer">View</a></u>
						
						</td>
						<td>
						
						<u style="background-color:  #0074A2; text-align:center;color:#FFF; border: 2px solid; min-width:50px; display:block;
		border-radius: 50px;text-decoration:none;" ><a style="color:#FFF; text-decoration:none" href="admin.php?page=member_add&act=upd&id=<?php echo $id;?>&type=customer">Edit</a></u>
						
						</td>
						
					</tr>
				<?php
				
			}		

	} else { ?>
			<tr>
				<td>No Record Found!</td>
			<tr>
	<?php } ?>
	
	
	
	</tbody>
	</table>
</div>
<?php if($type=='customer'){ ?>
<script>
jQuery("#toplevel_page_admin-page-memberlist-type-customer" ).removeClass();
jQuery("#toplevel_page_admin-page-memberlist-type-customer" ).addClass( "wp-has-submenu wp-has-current-submenu wp-menu-open menu-top menu-icon-generic toplevel_page_myplug/muyplg" );
jQuery("#toplevel_page_admin-page-memberlist-type-customer").css("background-color", "#0074a2");
</script>
<?php } else {?>

<script>
jQuery("#toplevel_page_admin-page-memberlist-type-photographers" ).removeClass();
jQuery("#toplevel_page_admin-page-memberlist-type-photographers" ).addClass( "wp-has-submenu wp-has-current-submenu wp-menu-open menu-top menu-icon-generic toplevel_page_myplug/muyplg" );
jQuery("#toplevel_page_admin-page-memberlist-type-photographers").css("background-color", "#0074a2");
</script>
<?php } ?>
